package com.nbsaas.boot.scm.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.math.BigDecimal;
import java.util.Date;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "采购申请单", model = "采购申请单")
@Entity
@Table(name = "bs_purchase_requisition")
@Comment("采购申请单表")
public class PurchaseRequisition extends AbstractEntity {

    @Comment("申请单编号")
    @SearchItem(name = "requisitionNo", key = "requisitionNo", label = "申请单编号")
    @FormField(title = "申请单编号", sortNum = "1", grid = true, required = true)
    @Column(length = 50, nullable = false, unique = true)
    private String requisitionNo;

    @Comment("申请单标题")
    @SearchItem(name = "title", key = "title", label = "申请单标题")
    @FormField(title = "申请单标题", sortNum = "2", grid = true, required = true)
    @Column(length = 200, nullable = false)
    private String title;

    @Comment("申请类型")
    @FormField(title = "申请类型", sortNum = "3", grid = true, type = InputType.select)
    @Column(length = 50)
    private String requisitionType; // MATERIAL-物料申请, EQUIPMENT-设备申请, SERVICE-服务申请, OFFICE-办公用品申请

    @Comment("申请优先级")
    @FormField(title = "申请优先级", sortNum = "4", grid = true, type = InputType.select)
    @Column(length = 20)
    private String priority; // URGENT-紧急, HIGH-高, NORMAL-普通, LOW-低

    @Comment("申请状态")
    @FormField(title = "申请状态", sortNum = "5", grid = true, type = InputType.select)
    @Column(length = 20)
    private String requisitionStatus; // DRAFT-草稿, SUBMITTED-已提交, APPROVED-已审批, REJECTED-已拒绝, CONVERTED-已转采购订单

    @Comment("审批状态")
    @FormField(title = "审批状态", sortNum = "6", grid = true, type = InputType.select)
    @Column(length = 20)
    private String approvalStatus; // PENDING-待审批, APPROVED-已审批, REJECTED-已拒绝

    @Comment("申请人ID")
    @FormField(title = "申请人", sortNum = "7", grid = true, type = InputType.select, required = true)
    private Long requesterId;

    @Comment("申请人姓名")
    @FormField(title = "申请人姓名", sortNum = "8", grid = true)
    @Column(length = 100)
    private String requesterName;

    @Comment("申请部门ID")
    @FormField(title = "申请部门", sortNum = "9", grid = true, type = InputType.select, required = true)
    private Long departmentId;

    @Comment("申请部门名称")
    @FormField(title = "申请部门名称", sortNum = "10", grid = true)
    @Column(length = 100)
    private String departmentName;

    @Comment("预计需求日期")
    @FormField(title = "预计需求日期", sortNum = "11", type = InputType.date, grid = true, required = true)
    private Date expectedNeedDate;

    @Comment("实际需求日期")
    @FormField(title = "实际需求日期", sortNum = "12", type = InputType.date, grid = true)
    private Date actualNeedDate;

    @Comment("申请总金额")
    @FormField(title = "申请总金额", sortNum = "13", grid = true, type = InputType.el_input_number, sort = true)
    @Column(precision = 15, scale = 2)
    private BigDecimal totalAmount;

    @Comment("预算金额")
    @FormField(title = "预算金额", sortNum = "14", grid = true, type = InputType.el_input_number)
    @Column(precision = 15, scale = 2)
    private BigDecimal budgetAmount;

    @Comment("超预算金额")
    @FormField(title = "超预算金额", sortNum = "15", grid = true, type = InputType.el_input_number)
    @Column(precision = 15, scale = 2)
    private BigDecimal overBudgetAmount;

    @Comment("申请原因")
    @FormField(title = "申请原因", sortNum = "16", type = InputType.textarea, required = true)
    @Column(columnDefinition = "text", nullable = false)
    private String requisitionReason;

    @Comment("技术要求")
    @FormField(title = "技术要求", sortNum = "17", type = InputType.textarea)
    @Column(columnDefinition = "text")
    private String technicalRequirements;

    @Comment("质量要求")
    @FormField(title = "质量要求", sortNum = "18", type = InputType.textarea)
    @Column(columnDefinition = "text")
    private String qualityRequirements;

    @Comment("交货要求")
    @FormField(title = "交货要求", sortNum = "19", type = InputType.textarea)
    @Column(columnDefinition = "text")
    private String deliveryRequirements;

    @Comment("推荐供应商")
    @FormField(title = "推荐供应商", sortNum = "20", grid = true)
    @Column(length = 200)
    private String recommendedSupplier;

    @Comment("审批意见")
    @FormField(title = "审批意见", sortNum = "21", type = InputType.textarea)
    @Column(columnDefinition = "text")
    private String approvalComment;

    @Comment("审批人ID")
    @FormField(title = "审批人", sortNum = "22", grid = true, type = InputType.select)
    private Long approverId;

    @Comment("审批人姓名")
    @FormField(title = "审批人姓名", sortNum = "23", grid = true)
    @Column(length = 100)
    private String approverName;

    @Comment("审批时间")
    @FormField(title = "审批时间", sortNum = "24", type = InputType.date, grid = true)
    private Date approvalTime;

    @Comment("备注")
    @FormField(title = "备注", sortNum = "25", type = InputType.textarea)
    @Column(columnDefinition = "text")
    private String remark;
} 